<?php

// Parse the parameters from the Ajax.Request

if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER ['HTTP_X_REQUESTED_WITH']  == 'XMLHttpRequest') {
	require('../../../../wp-config.php');
	auth_redirect();
	
	global $wpdb, $canvas;
	
	foreach ($_GET as $key => $values) {
	  if (!empty($values)) {
		foreach ($values as $k => $value) {
	
		 if ($key != "_") {
		
			// $key holds the zone name
			// $k is the index for each block in that zone's array of blocks
			// $value is the block_id
					
			$position = $k + 1;
			$newzone = $key;
			$block_id = $value;
							
			if ($wpdb->get_var("SELECT block_id FROM ".$canvas->main." WHERE block_id='$block_id'"))
				$wpdb->query("UPDATE ".$canvas->main." SET zone='$newzone', position='$position' WHERE block_id='$block_id'");
		  }
		}
	  }
	}
}
?>